package com.skycong.hello77.activity.viewpager_own;


import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;


public class VpSimpleFragment extends Fragment {
    private  String mTitle;

    private  static  final String  BUNDLE_TITLE="titile";

    //在onCreateView中拿到这个bundel;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        Bundle bundle =getArguments();
        if(bundle!=null){
            mTitle=bundle.getString(BUNDLE_TITLE);
        }
        //直接创建一个TextView
        TextView tv = new TextView(getContext());
        tv.setText(mTitle);
        tv.setGravity(Gravity.CENTER);
        return tv;
    }

    public static VpSimpleFragment newInstance(String title){
        Bundle bundle = new Bundle();
        bundle.putString(BUNDLE_TITLE,title);
        VpSimpleFragment fragment  = new VpSimpleFragment();
        fragment.setArguments(bundle);
        return fragment;
    }
}
